//
//  SaveCell.m
//  ZFJFormKit
//
//  Created by 张福杰 on 2018/4/24.
//  Copyright © 2019 张福杰. All rights reserved.
//

#import "SaveCell.h"
#import "ZFJFormKit.h"

#define ScreenWidth    [UIScreen mainScreen].bounds.size.width

#define ScreenHeight   [UIScreen mainScreen].bounds.size.height

@interface SaveCell ()<ZFJFormCellDelegate>

@property (nonatomic,strong) ZFJFormModel *model;

@end

@implementation SaveCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self uiConfig];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)uiConfig{
    [self.contentView addSubview:self.saveBtn];
    
    self.saveBtn.frame = CGRectMake((ScreenWidth - 250)/2, 40, 250, 45);
    self.saveBtn.layer.masksToBounds = YES;
    self.saveBtn.layer.cornerRadius = 5.0;
    
    self.backgroundColor = [UIColor groupTableViewBackgroundColor];
}

- (void)configCellWithModel:(ZFJFormModel *)model{
    NSLog(@"aaaaaaa");
    _model = model;
}

- (void)saveBtnClick:(UIButton *)button{
    //自定义CELL的事件处理
    if(_model != nil && _model.customCellEventBlock){
        _model.customCellEventBlock(button);
    }
}

- (UIButton *)saveBtn{
    if(_saveBtn == nil){
        _saveBtn = [[UIButton alloc] init];
        [_saveBtn setTitle:@"保  存" forState:UIControlStateNormal];
        _saveBtn.backgroundColor = [UIColor blueColor];
        [_saveBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _saveBtn.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:16];
        [_saveBtn addTarget:self action:@selector(saveBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _saveBtn;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
